package org.deltaset.faces.upload;

import org.apache.commons.codec.binary.Base64;

/**
 *
 * @author dmakariev
 */
public class Base64Util {

    //the used Apache Commons method is not thread-safe:
    // http://commons.apache.org/codec/apidocs/org/apache/commons/codec/binary/Base64.html
    public static String encode(final String initial) {
        return new String(Base64.encodeBase64URLSafeString(initial.getBytes()));
    }

    public static String decode(String encoded) {
        return new String(Base64.decodeBase64(encoded));
    }
}
